package com.beiing.tianshuai.tianshuai.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Jinni on 2017/12/8 0008
 */

public class InterestVideoCheckUtil {
    /**
     * 返回单个字符串，若匹配到多个的话就返回第一个，方法与getSubUtil一样
     *
     * @param soap  原始字符串
     * @param regex 正则
     * @return 结果
     */
    private static String getSubUtilSimple(String soap, String regex) {
        Pattern pattern = Pattern.compile(regex);// 匹配的模式
        Matcher m = pattern.matcher(soap);
        if (m.find()) {
            return m.group(0);
        }
        return "";
    }

    public static String iframeCode(String code) {
        String regex = "(?i)(?<=src=\"|src=')[^\"]*(?=\"|')";
        return getSubUtilSimple(code, regex);
    }
}